<template>
  <div v-loading="loading">
    <el-form :model="form" label-position="left" inline class="demo-table-expand">
      <el-form-item label="标题" prop="title" style="height: 100px">
        <span v-html="form.title" />
      </el-form-item>
      <el-form-item label="发布时间" prop="releaseTime" style="height: 100px">
        {{ form.releaseTime | timeFilter }}
      </el-form-item>
      <el-form-item label="公告内容" prop="content" style="height: 100px">
        <span v-html="form.content" />
      </el-form-item>
      <el-form-item label="发布人" prop="releaseUser" style="height: 100px">
        <span v-html="form.releaseUserName" />
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getMsgSend } from '@/api/system/message/msgSend'

import moment from 'moment'
export default {
  filters: {
    timeFilter(timeStamp) {
      return moment(timeStamp).format('YYYY-MM-DD HH:mm')
    }
  },
  data() {
    return {
      // 表单参数
      form: {
      },
      // 遮罩层
      loading: false
    }
  },
  created() {
  },
  mounted() {
    this.$bus.$emit('async_done')
  },
  methods: {
    // 初始化数据
    init(data) {
      this.loading = true
      if (data != null && data.id !== undefined) {
        getMsgSend(data.id).then(response => {
          this.form = response.data
          this.loading = false
        })
      } else {
        this.reset()
        this.loading = false
      }
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,

        title: undefined,

        content: undefined,

        releaseTime: undefined,

        releaseUser: undefined,

        createBy: undefined,

        createTime: undefined,

        updateBy: undefined,

        updateTime: undefined

      }
      this.resetForm('form')
    }

  }
}
</script>
<style lang="scss" scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
